package com.witmore.neutron.ai.web.controller;

import okhttp3.*;

import java.io.IOException;

/**
 * @author 豆子高
 * @date 2025-05-26 11:41
 */
public class JiMoApiController {

    public static void main(String[] args) throws IOException {
        sendMessage();
    }


    public static void sendMessage() throws IOException {
        OkHttpClient client = new OkHttpClient().newBuilder()
                .build();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n            \"role\": \"user\",\n            \"content\": \"Hello\"\n        }\n    ],\n    \"sessionId\": \"90\",\n    \"source\": \"api\",\n    \"stream\": true,\n    \"extra\": {}\n}");
        Request request = new Request.Builder()
                .url("https://jimoai-bot-api.xiaohuodui.cn/v2/chat/completions/share?shareId=RseLQSEbqpBEpeIC")
                .method("POST", body)
                .addHeader("Authorization", "V2l0bW9yZTo4NDYzOTliM2U1ZWQ2MmRiMWM1OTE4N2NmMzA3MjA1Yg==")
                .addHeader("Content-Type", "application/json")
                .build();
        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());
    }


    public static void sendMessageAndPic() throws IOException {
        OkHttpClient client = new OkHttpClient().newBuilder()
                .build();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\n    \"source\": \"api\",\n    \"url\": \"https://jimo-ai-1256913022.cos.ap-shanghai.myqcloud.com/jimochat/img/1740385113282_%E8%AE%B2%E7%A8%BF.docx\",\n    \"name\": \"讲稿\",\n    \"size\": 32,\n    \"sizeType\": \"KB\",\n    \"type\": \"docx\"\n}");
        Request request = new Request.Builder()
                .url("https://jimoai-bot-api.xiaohuodui.cn/v2/chat/completions/share?shareId=xwuo7WJPihH26184")
                .method("POST", body)
                .addHeader("Authorization", "V2l0bW9yZTo4NDYzOTliM2U1ZWQ2MmRiMWM1OTE4N2NmMzA3MjA1Yg==")
                .addHeader("Content-Type", "application/json")
                .build();
        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());
    }
}
